﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：UserIdentifier.cs
// 功能描述：TongTongMall
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TongTongMall.Extensions;

namespace TongTongMall.Tenant
{
    [Serializable]
    public class UserIdentifier : IUserIdentifier
    {
        /// <summary>
        /// 租户Id
        /// </summary>
        public long? TenantID { get; protected set; }

        /// <summary>
        /// 用户Id
        /// </summary>
        public long? UserID { get; protected set; }


        protected UserIdentifier()
        {

        }

        public UserIdentifier(long? tenantId, long? userId)
        {
            TenantID = tenantId;
            UserID = userId;
        }

        public string ToUserIdentifierString()
        {
            if (TenantID == null)
            {
                return UserID.ToString();
            }

            return TenantID + ":" + UserID;
        }
    }
}
